import { list, exportList, getHouseInfoById, addHouse, putHouseInfoById, delHouseInfoById, allInfolist, getSysUser } from '@/api/apartment/apartmentBuilding'

const data = {
  state: {
    list: [],
    allRooms: [],
    sysUserList: []
  },

  mutations: {
    SET_list: (state, list) => {
      state.list = list
    },
    SET_Alllist: (state, list) => {
      state.allRooms = list
    },
    SET_SysUserlist: (state, list) => {
      state.sysUserList = list
    },

  }, 

  actions: {
    // 获取列表
    async getTable({ commit }, params) {
      const { rows, code, total } = await list({ pageSize: 999999, ...params });
      commit("SET_list", rows)
      return { rows, code, total }
    },

    async exportList({ commit }, params) {
      const { data, code } = await exportList(params);
      return { data, code }
    },

    async getHouseInfoById({ commit }, params) {
      const { data, code } = await getHouseInfoById(params);
      return { data, code }
    },

    async addHouse({ commit }, params) {
      const { data, code } = await addHouse(params);
      return { data, code }
    },

    async putHouseInfoById({ commit }, params) {
      const { data, code } = await putHouseInfoById(params);
      return { data, code }
    },

    async delHouseInfoById({ commit }, params) {
      const { data, code } = await delHouseInfoById(params);
      return { data, code }
    },

    async allInfolist({ commit }, params) {
      const data = await allInfolist(params);
      commit("SET_Alllist", data)
      return data
    },

    async getSystemUser({ commit }, params) {
      const { rows, code } = await getSysUser({ pageSize: 999999,...params});
      commit("SET_SysUserlist", rows)
      return data
    },



  },
  namespaced: true,
}

export default data
